The FTrace class

The FTrace class allows you to inspect the data for the run. Its main purpose is to parse the trace information into pandas DataFrames. Each tracepoint gets its own DataFrame.

First some hacks to allow importing trappy from here


In [1]:
import sys
sys.path.append("..")

In [2]:
%matplotlib inline
import trappy


Populating the interactive namespace from numpy and matplotlib

The FTrace class has one mandatory parameter: the path to trace.dat or trace.txt.


In [3]:
trace = trappy.FTrace("./trace.txt")

You can access the DataFrame for each tracepoint using the .data_frame property. For example, the trace_thermal tracepoint is in the .thermal property of FTrace


In [4]:
trace.thermal.data_frame


Out[4]:
__comm __cpu __pid id temp temp_prev thermal_zone
Time
0.000000 kworker/4:1 4 51 0 68786 68794 soc_thermal
0.099539 kworker/4:1 4 51 0 68781 68786 soc_thermal
0.199957 kworker/4:1 4 51 0 68782 68781 soc_thermal
0.299112 kworker/4:1 4 51 0 68835 68782 soc_thermal
0.399646 kworker/4:1 4 51 0 68882 68835 soc_thermal
0.499651 kworker/4:1 4 51 0 68907 68882 soc_thermal
0.609645 kworker/4:1 4 51 0 68943 68907 soc_thermal
0.708361 kworker/4:1 4 51 0 68959 68943 soc_thermal
0.810043 kworker/4:1 4 51 0 68947 68959 soc_thermal
0.909460 kworker/4:1 4 51 0 68950 68947 soc_thermal
1.008723 kworker/4:1 4 51 0 68952 68950 soc_thermal
1.108719 kworker/4:1 4 51 0 68965 68952 soc_thermal
1.209270 kworker/4:1 4 51 0 68978 68965 soc_thermal
1.309819 kworker/4:1 4 51 0 68989 68978 soc_thermal
1.408818 kworker/4:1 4 51 0 69007 68989 soc_thermal
1.509182 kworker/4:1 4 51 0 69008 69007 soc_thermal
1.619889 kworker/4:1 4 51 0 68996 69008 soc_thermal
1.718734 kworker/4:1 4 51 0 68990 68996 soc_thermal
1.819079 kworker/4:1 4 51 0 69007 68990 soc_thermal
1.918692 kworker/4:1 4 51 0 69026 69007 soc_thermal
2.018747 kworker/4:1 4 51 0 69074 69026 soc_thermal
2.118722 kworker/4:1 4 51 0 69113 69074 soc_thermal
2.219281 kworker/4:1 4 51 0 69131 69113 soc_thermal
2.319764 kworker/4:1 4 51 0 69161 69131 soc_thermal
2.419244 kworker/4:1 4 51 0 69155 69161 soc_thermal
2.519402 kworker/4:1 4 51 0 69203 69155 soc_thermal
2.618870 kworker/4:1 4 51 0 69229 69203 soc_thermal
2.718664 kworker/4:1 4 51 0 69269 69229 soc_thermal
2.818393 kworker/4:1 4 51 0 69294 69269 soc_thermal
2.919531 kworker/4:1 4 51 0 69313 69294 soc_thermal
... ... ... ... ... ... ... ...
3.719973 kworker/4:1 4 51 0 69498 69480 soc_thermal
3.818846 kworker/4:1 4 51 0 69513 69498 soc_thermal
3.919578 kworker/4:1 4 51 0 69556 69513 soc_thermal
4.018333 kworker/4:1 4 51 0 69607 69556 soc_thermal
4.118291 kworker/4:1 4 51 0 69647 69607 soc_thermal
4.219773 kworker/4:1 4 51 0 69657 69647 soc_thermal
4.318951 kworker/4:1 4 51 0 69663 69657 soc_thermal
4.419577 kworker/4:1 4 51 0 69685 69663 soc_thermal
4.519842 kworker/4:1 4 51 0 69710 69685 soc_thermal
4.618309 kworker/4:1 4 51 0 69733 69710 soc_thermal
4.719834 kworker/4:1 4 51 0 69714 69733 soc_thermal
4.818769 kworker/4:1 4 51 0 69700 69714 soc_thermal
4.920188 kworker/4:1 4 51 0 69667 69700 soc_thermal
5.022114 kworker/4:1 4 51 0 69621 69667 soc_thermal
5.119599 kworker/4:1 4 51 0 69577 69621 soc_thermal
5.218946 kworker/4:1 4 51 0 69546 69577 soc_thermal
5.319060 kworker/4:1 4 51 0 69530 69546 soc_thermal
5.418773 kworker/4:1 4 51 0 69509 69530 soc_thermal
5.528891 kworker/4:1 4 51 0 69523 69509 soc_thermal
5.628737 kworker/4:1 4 51 0 69515 69523 soc_thermal
5.728319 kworker/4:1 4 51 0 69489 69515 soc_thermal
5.829462 kworker/4:1 4 51 0 69469 69489 soc_thermal
5.928346 kworker/4:1 4 51 0 69478 69469 soc_thermal
6.029079 kworker/4:1 4 51 0 69453 69478 soc_thermal
6.139673 kworker/4:1 4 51 0 69442 69453 soc_thermal
6.248760 kworker/4:1 4 51 0 69427 69442 soc_thermal
6.349737 kworker/4:1 4 51 0 69406 69427 soc_thermal
6.458919 kworker/4:1 4 51 0 69424 69406 soc_thermal
6.559456 kworker/4:1 4 51 0 69418 69424 soc_thermal
6.658977 kworker/4:1 4 51 0 69417 69418 soc_thermal

67 rows × 7 columns

You can use pandas' infrastructure to filter data. For example, the cpu_in_power trace has information for both clusters


In [5]:
trace.cpu_in_power.data_frame.head()


Out[5]:
__comm __cpu __pid cpus dynamic_power freq load0 load1 load2 load3 static_power
Time
0.002264 kworker/4:1 4 51 00000000,00000006 250 1100000 24 19 0 0 178
0.002279 kworker/4:1 4 51 00000000,00000039 166 850000 36 49 48 7 131
0.100949 kworker/4:1 4 51 00000000,00000006 227 1100000 28 11 0 0 178
0.100970 kworker/4:1 4 51 00000000,00000039 178 850000 32 28 46 44 131
0.200914 kworker/4:1 4 51 00000000,00000006 256 1100000 20 24 0 0 178

We can filter it to return only the data for cpus "00000000,00000039":


In [6]:
trace.cpu_in_power.data_frame[trace.cpu_in_power.data_frame.cpus == "00000000,00000039"]


Out[6]:
__comm __cpu __pid cpus dynamic_power freq load0 load1 load2 load3 static_power
Time
0.002279 kworker/4:1 4 51 00000000,00000039 166 850000 36 49 48 7 131
0.100970 kworker/4:1 4 51 00000000,00000039 178 850000 32 28 46 44 131
0.200929 kworker/4:1 4 51 00000000,00000039 174 850000 28 44 42 33 131
0.300253 kworker/4:1 4 51 00000000,00000039 166 850000 52 31 49 8 131
0.401033 kworker/4:1 4 51 00000000,00000039 197 850000 38 39 34 55 131
0.500595 kworker/4:1 4 51 00000000,00000039 149 850000 46 48 4 28 131
0.610771 kworker/4:1 4 51 00000000,00000039 168 850000 42 64 20 16 131
0.709190 kworker/4:1 4 51 00000000,00000039 190 850000 80 41 23 16 131
0.811388 kworker/4:1 4 51 00000000,00000039 185 850000 56 60 10 30 131
0.910507 kworker/4:1 4 51 00000000,00000039 171 850000 29 25 43 47 131
1.009501 kworker/4:1 4 51 00000000,00000039 159 850000 33 29 52 20 131
1.109501 kworker/4:1 4 51 00000000,00000039 208 850000 38 36 93 8 131
1.210615 kworker/4:1 4 51 00000000,00000039 207 850000 38 35 27 74 131
1.311017 kworker/4:1 4 51 00000000,00000039 164 850000 22 24 68 24 131
1.409793 kworker/4:1 4 51 00000000,00000039 180 850000 48 30 7 67 137
1.510247 kworker/4:1 4 51 00000000,00000039 195 850000 92 44 11 17 137
1.621442 kworker/4:1 4 51 00000000,00000039 172 850000 25 25 63 32 131
1.719513 kworker/4:1 4 51 00000000,00000039 165 850000 69 45 18 7 131
1.820367 kworker/4:1 4 51 00000000,00000039 148 850000 41 37 40 7 137
1.919996 kworker/4:1 4 51 00000000,00000039 111 850000 42 39 6 7 137
2.020034 kworker/4:1 4 51 00000000,00000039 161 850000 44 39 8 45 137
2.119842 kworker/4:1 4 51 00000000,00000039 130 850000 31 26 6 47 137
2.220430 kworker/4:1 4 51 00000000,00000039 167 850000 61 57 17 6 137
2.321255 kworker/4:1 4 51 00000000,00000039 166 850000 40 24 57 19 137
2.420036 kworker/4:1 4 51 00000000,00000039 170 850000 57 38 38 10 137
2.520509 kworker/4:1 4 51 00000000,00000039 117 850000 40 36 17 6 137
2.620426 kworker/4:1 4 51 00000000,00000039 129 850000 56 25 22 6 137
2.719428 kworker/4:1 4 51 00000000,00000039 173 850000 44 29 66 7 137
2.819184 kworker/4:1 4 51 00000000,00000039 185 850000 42 40 62 12 137
2.921334 kworker/4:1 4 51 00000000,00000039 172 850000 26 23 30 66 137
... ... ... ... ... ... ... ... ... ... ... ...
3.721862 kworker/4:1 4 51 00000000,00000039 91 850000 33 29 9 6 137
3.820099 kworker/4:1 4 51 00000000,00000039 142 850000 54 51 9 6 137
3.920987 kworker/4:1 4 51 00000000,00000039 122 850000 34 27 8 34 137
4.019102 kworker/4:1 4 51 00000000,00000039 154 850000 38 34 19 39 137
4.119037 kworker/4:1 4 51 00000000,00000039 185 850000 36 29 79 12 137
4.221545 kworker/4:1 4 51 00000000,00000039 119 850000 25 23 32 20 137
4.320729 kworker/4:1 4 51 00000000,00000039 186 850000 30 28 64 35 137
4.421109 kworker/4:1 4 51 00000000,00000039 168 850000 52 48 11 31 137
4.521129 kworker/4:1 4 51 00000000,00000039 171 850000 28 23 10 83 137
4.619289 kworker/4:1 4 51 00000000,00000039 179 850000 29 25 54 43 137
4.721126 kworker/4:1 4 51 00000000,00000039 224 850000 45 44 84 16 137
4.820703 kworker/4:1 4 51 00000000,00000039 166 850000 26 24 7 83 137
4.921670 kworker/4:1 4 51 00000000,00000039 163 850000 44 22 7 64 137
5.022998 kworker/4:1 4 51 00000000,00000039 216 850000 46 41 84 11 137
5.120968 kworker/4:1 4 51 00000000,00000039 174 850000 49 26 37 35 137
5.220168 kworker/4:1 4 51 00000000,00000039 152 850000 25 46 8 49 137
5.320038 kworker/4:1 4 51 00000000,00000039 167 850000 78 31 28 4 137
5.419996 kworker/4:1 4 51 00000000,00000039 190 850000 47 52 17 44 137
5.530364 kworker/4:1 4 51 00000000,00000039 141 850000 34 74 7 4 137
5.629523 kworker/4:1 4 51 00000000,00000039 177 850000 34 51 5 59 137
5.729082 kworker/4:1 4 51 00000000,00000039 199 850000 40 52 26 50 137
5.830771 kworker/4:1 4 51 00000000,00000039 155 850000 26 41 31 33 137
5.929531 kworker/4:1 4 51 00000000,00000039 184 850000 34 27 31 63 137
6.030359 kworker/4:1 4 51 00000000,00000039 199 850000 61 40 40 27 137
6.141069 kworker/4:1 4 51 00000000,00000039 151 850000 43 22 38 24 137
6.251660 kworker/4:1 4 51 00000000,00000039 201 850000 40 36 55 38 137
6.351220 kworker/4:1 4 51 00000000,00000039 160 850000 34 89 6 6 137
6.460227 kworker/4:1 4 51 00000000,00000039 170 850000 48 49 20 26 137
6.560918 kworker/4:1 4 51 00000000,00000039 180 850000 64 37 42 9 137
6.659959 kworker/4:1 4 51 00000000,00000039 164 850000 26 57 20 35 137

67 rows × 11 columns

Custom trace events

The FTrace() object by default parses a number of thermal and scheduler classes that are known to trappy. If you know which events you are interested in, you can create a FTrace() object that only parses those. For example, if you have collected your trace with

trace-cmd -e thermal_temperature cdev_update

you can get a custom FTrace object that only parses those:


In [7]:
trace_custom = trappy.FTrace("./trace.txt", scope="custom", events=["thermal_temperature", "cdev_update"])

In [8]:
trace_custom.thermal_temperature.data_frame.head()


Out[8]:
__comm __cpu __pid id temp temp_prev thermal_zone
Time
0.000000 kworker/4:1 4 51 0 68786 68794 soc_thermal
0.099539 kworker/4:1 4 51 0 68781 68786 soc_thermal
0.199957 kworker/4:1 4 51 0 68782 68781 soc_thermal
0.299112 kworker/4:1 4 51 0 68835 68782 soc_thermal
0.399646 kworker/4:1 4 51 0 68882 68835 soc_thermal

Writing to CSV

You can use the .write_csv() method of each tracepoint class to output the trace to CSV for analyzing with other programs. For example, let's write the trace_thermal_power_allocator tracepoint information (available in the .thermal_governor property of the FTrace instance) to file thermal_power_allocator.csv


In [9]:
trace.thermal_governor.write_csv("thermal_power_allocator.csv")